import numpy as np

# 创建示例数据
batch_size = 3
input_size = 4
hidden_size = 2

# 模拟数据
X = np.array([[1, 2, 3, 4],      # 样本1
              [0.5, 1.5, 2.5, 3.5],  # 样本2
              [2, 1, 4, 3]])     # 样本3

W1 = np.array([[0.1, 0.2],       # 输入1到隐藏层的权重
               [0.3, 0.4],       # 输入2到隐藏层的权重
               [0.5, 0.6],       # 输入3到隐藏层的权重
               [0.7, 0.8]])      # 输入4到隐藏层的权重

b1 = np.array([[0.1, 0.2]])      # 隐藏层偏置


def sigmoid(self, x):
        """Sigmoid激活函数"""
        return 1 / (1 + np.exp(-np.clip(x, -250, 250)))  # 防止数值溢出


# 计算 z1
temp = np.dot(X, W1)
print("计算结果 temp:")
print(temp)
print(f"形状: {temp.shape}")

# 计算 z1
z1 = np.dot(X, W1) + b1
print("输入数据 X:")
print(X)
print(f"形状: {X.shape}\n")

print("权重矩阵 W1:")
print(W1)
print(f"形状: {W1.shape}\n")

print("偏置 b1:")
print(b1)
print(f"形状: {b1.shape}\n")

print("计算结果 z1:")
print(z1)
print(f"形状: {z1.shape}")


a1 = sigmoid(z1)
print("计算结果 a1:")
print(a1)
print(f"形状: {a1.shape}")